package com.learn.jdk.dataapi;

import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @author: lipan
 * @date: 2021/5/19 20:58
 */

public class Demo1 {


    public static void main(String[] args) {

        //获取当前日期
        Date date=new Date();

        System.out.println(date);

        //1900年+121 1+4month 0+19day
        Date date2=new Date(121,4,19);
        System.out.println(date2);

        //非线程安全的api
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            ExecutorService scheduledExecutorService = Executors.newFixedThreadPool(4);


        for (int i = 0; i <1000 ; i++) {
             scheduledExecutorService.execute(()->{


                 try {
                     Date parse = sdf.parse("2018-12-22 20:09:11");
                     System.out.println("["+Thread.currentThread().getName()+"]"+parse);
                 } catch (ParseException e) {
                     e.printStackTrace();
                 }

             });
        }


            scheduledExecutorService.shutdown();
    }





}
